aboutsummaryrefslogtreecommitdiff
path: root/src/routes/projects/[id]/+page.server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/projects/[id]/+page.server.ts')
-rw-r--r--src/routes/projects/[id]/+page.server.ts23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/routes/projects/[id]/+page.server.ts b/src/routes/projects/[id]/+page.server.ts
index 83d7571..1df28c2 100644
--- a/src/routes/projects/[id]/+page.server.ts
+++ b/src/routes/projects/[id]/+page.server.ts
@@ -1,13 +1,5 @@
import { error, fail, redirect } from '@sveltejs/kit';
-import {
- archive as archiveProject,
- getById,
-} from '$lib/server/services/projects';
-import {
- add,
- loadProjectDashboard,
- loadArchived,
-} from '$lib/server/services/routines';
+import { projectsService, routinesService } from '$lib/server/services';
import { completeRoutineAction } from '$lib/server/services/routine-actions';
import { numericId, parseFormString } from '$lib/server/services/validation';
import { Frequency } from '$lib/shared/frequency';
@@ -15,12 +7,15 @@ import type { Actions, PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params }) => {
const id = numericId(params.id);
- const project = await getById(id);
+ const project = await projectsService.getById(id);
if (!project || project.archived) {
throw error(404, 'Projet introuvable');
}
- const dashboard = await loadProjectDashboard(id, Temporal.Now.instant());
- const archived = await loadArchived(id);
+ const dashboard = await routinesService.loadProjectDashboard(
+ id,
+ Temporal.Now.instant(),
+ );
+ const archived = await routinesService.loadArchived(id);
return {
project: { id: project.id, name: project.name },
routines: dashboard.routines,
@@ -38,7 +33,7 @@ export const actions: Actions = {
return fail(400, { error: 'Le nom est requis' });
}
try {
- await add(
+ await routinesService.add(
numericId(params.id),
name,
Frequency.parse(data.get('frequency')?.toString() ?? '').toSpec(),
@@ -55,7 +50,7 @@ export const actions: Actions = {
},
archiveProject: async ({ params }) => {
- await archiveProject(numericId(params.id));
+ await projectsService.archive(numericId(params.id));
throw redirect(303, '/');
},
};